<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>问题和反馈页面</title>
    <link rel="stylesheet" type="text/css" href="${ctxPath}/static/assets/aui/css/aui.css" />
    <!-- jQuery Include -->
    <script type="text/javascript" src="${ctxPath}/static/assets/scripts/jquery.min.js"></script>
    <style>

        .aui-list-item-title{
           color:  #757575;
            font-size: 14px;
            font-style: normal;
            font-family: auto;
            font-weight: normal;
        }
    </style>
</head>
<body>
<div class="aui-content aui-margin-b-15">
    <ul class="aui-list aui-media-list">
        <li >
            <header class="aui-bar aui-bar-nav">
                <a class="aui-pull-left aui-btn" onclick='retn()'>
                    <span class="aui-iconfont aui-icon-left"></span>返回
                </a>
                <div class="aui-title">选择问题类型</div>
            </header>
        </li>
    </ul>
</div>
<section class="aui-content">
    <ul class="aui-list" id="content">
    </ul>
</section>
</body>
<script>
    var  user=localStorage.getItem("userInfo");//以“key”为名称存储一个值“value”
    if(!user){
        location.href="${ctxPath}/wechat/public/toLoginPage";//未实现
    }
    $("#img").show();
    var obj = JSON.parse(user); // --> parse error

    $(function(){
        init();
    })
    function init() {
        var  questions=localStorage.getItem("questions");//以“key”为名称存储一个值“value”
        if(!questions||JSON.parse(questions).length==0){//不存在
            $.ajax({
                type: "POST",
                url: "${ctxPath}/knowledgeBase/searchAll",
                dataType: "json",
                success: function (result) {
                    localStorage.setItem("questions",JSON.stringify(result));//以“key”为名称存储一个值“value”
                    var  str="";
                    for(var i=0;i<result.length;i++){
                        var  question=result[i];
                        str+="<li class=\"aui-list-item\" onclick='toSayQuestion("+question.id+")'>\n" +
                            "            <div class=\"aui-list-item-inner\">\n" +
                            "                <div class=\"aui-list-item-title\" style='font-size: 0.7rem;color: #666666;'>"+question.problem+"</div>\n" +
                            "            </div>\n" +
                            "        </li>";
                    }
                    $("#content").html(str);
                }
            });
        }
        var result = JSON.parse(questions); // 存在
        var  str="";
        for(var i=0;i<result.length;i++){
            var  question=result[i];
            str+="<li class=\"aui-list-item\" onclick='toSayQuestion("+question.id+")'>\n" +
                "            <div class=\"aui-list-item-inner\">\n" +
                "                <div class=\"aui-list-item-title\" style='font-size: 0.7rem;color: #666666;'>"+question.problem+"</div>\n" +
                "            </div>\n" +
                "        </li>";
        }
        $("#content").html(str);
    }

    function retn() {
        location.href ="${ctxPath}/wechat/public/toMinePage";
    }
    //去反馈页面
    function toSayQuestion(id){
        location.href="${ctxPath}/wechat/public/toSayQuestion?id="+id;
    }
</script>
</html>